window.onload=function () {
    let _this;
    var app = new Vue({
        el: "#app",
        data: {
            pagination: {
                total: 0, //总记录数
                pageSize: 10, //每页的记录数
                pageNum: 1, //当前页码
            },
            articlearr:[],//所有未审核文章
            articleobj:{
                a_title:"",//标题
                tid:"",
                state:0,//状态 0 上架 1 删除 2 下架
                aid:"",//文章id
                name:"",//发布用户

            },
            toucharray:[],//所以类型
            lookallarticle:false,//查看文章按钮
            updateallarticle:false//修改文章按钮
        },
        methods: {
            inisarticleno(){
                //初始化数据
                methodaxios.get(null,"/article/listyes?currentPage="+this.pagination.pageNum+"&pageSize="+this.pagination.pageSize,rep=>{
                    this.articlearr=rep.data.data;
                    this.pagination.total=rep.data.count;
                });
            }, //查询属于文章的牙齿类型
            inittouch(){
                methodaxios.get(null,"/touch/listarticle",rep=>{
                    this.toucharray=rep.data
                });
            },//当前页发送改变
            findBlogPageList(page) {
                //页数改变
                this.pagination.pageNum = page;
                this.inisarticleno();
            }, //每页大小发送改变
            sizeChange(size) {
                this.pagination.pageSize = size; //当前页显示多少
                this.pagination.pageNum = 1;
                this.inisarticleno();
            },
            wantlookallarticle(row){//点击查看按钮
                this.lookallarticle=true
                this.articleobj.a_title=row.a_title
                this.articleobj.name=row.name
                var E = window.wangEditor
                var editor = new E('#editor')
                editor.create()
                editor.$textElem.attr('contenteditable', false)
                editor.txt.html('<p>' +row.a_content+'</p>' );
            },
            updateallarticlemetod(row){//点击修改按钮
                this.updateallarticle=true
                this.articleobj.a_title=row.a_title
                this.articleobj.name=row.name
                this.articleobj.tid=row.tid
                this.articleobj.aid=row.aid
                this.articleobj.state=row.state
                var E = window.wangEditor
                var editor = new E('#updateeditorarticle')
                editor.create()
                editor.$textElem.attr('contenteditable', false)
                editor.txt.html('<p>' +row.a_content+'</p>' );
            },
            confirmupdatearticle(){//确定修改

                window.console.log(this.articleobj.state)
             /*   if(this.articleobj.state!=0 || this.articleobj.state!=2){
                    layer.msg("请指定状态");
                    return false;
                }*/
                this.articleobj.name=""
                this.articleobj.a_title=""
                methodaxios.post("/article/update",this.articleobj,rep=>{
                    if(rep.data.code==="200"){
                        this.articleobj.tid=""
                        this.articleobj.state=""
                        this.articleobj.aid=""
                        layer.msg("修改成功");
                        this.updateallarticle=false
                        this.inisarticleno();
                    }
                });
            }
        },mounted(){
            _this=this;
            this.inittouch();
            this.inisarticleno();
        },
        filters:{
            mytime(value){
                var dateee = new Date( value).toJSON();
                return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
            },//状态(0 启用 1删除 2禁用)
            mystate(value){
                if(value=="0"){
                    return "上架"
                }else if(value=="1"){
                    return "已删除"
                }else if(value=="2"){
                    return "下架"
                }
            },
           mytype(value){
                for (var i=0;i<_this.toucharray.length;i++){
                    if(value===_this.toucharray[i].tid){
                        return _this.toucharray[i].name;
                    }
                }
            }
        }

    })
}
